package com.cybertron.lockdown.spider;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

/**
 * Created by xiezhouyan on 15-1-10.
 */
public class LockdownPipiline implements Pipeline {

    private final SiteManager siteManager;

    public LockdownPipiline(SiteManager siteManager) {
        this.siteManager = siteManager;
    }

    @Override
    public void process(ResultItems resultItems, Task task) {
        if (resultItems.getAll().size() != 0) {
            siteManager.getSite(resultItems.getRequest().getUrl()).listener().pipelineProcess(resultItems, task);
        }
    }
}
